using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SwitchController : MonoBehaviour
{
    public GameObject doorSwitch;
    public GameObject hideDoor;
    private Animator anim;
    private bool press = true;

    private void Start()
    {
        anim = GetComponent<Animator>();
    }
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.E) && doorSwitch.activeInHierarchy)
        {
            hideDoor.SetActive(press);
            anim.SetBool("Press", press);
            press = !press;

        }
    }
    private void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.tag == "Player")
        {
            doorSwitch.SetActive(true);

        }
    }
    private void OnTriggerExit2D(Collider2D collider)
    {
        if (collider.tag == "Player")
        {
            doorSwitch.SetActive(false);
        }
    }
}
